package com.longcai.piaojia.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.longcai.piaojia.R;
import com.longcai.piaojia.conn.Conn;
import com.zcx.helper.bound.BoundView;

/**
 * Created by Administrator on 2016/11/14.
 */
public class AdvertWebActivity extends BaseActivity implements View.OnClickListener {


    @BoundView(R.id.advert_web_wv) private WebView advert_web_wv;
    @BoundView(R.id.advert_web_time_tv) private TextView advert_web_time_tv;
    @BoundView(R.id.advert_web_rl) private RelativeLayout advert_web_rl;
    @BoundView(R.id.advert_web_time_ll) private LinearLayout advert_web_time_ll;

    private CountDownTimer countTime = new CountDownTimer(6000, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {

            advert_web_time_tv.setText(millisUntilFinished / 1000 + "");

        }

        @Override
        public void onFinish() {

            countTime.cancel();

            startActivity(new Intent(AdvertWebActivity.this, NavigationActivity.class));

            finish();

        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_advert_web);

        advert_web_wv.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {

                advert_web_rl.setVisibility(View.VISIBLE);

                countTime.start();

                super.onPageFinished(view, url);
            }
        });

        advert_web_wv.loadUrl(Conn.SERVICE + Conn.INDEX_GUIDE_WEB);


        advert_web_time_ll.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.advert_web_time_ll:

                countTime.cancel();

                startActivity(new Intent(AdvertWebActivity.this, NavigationActivity.class));

                finish();

                break;
        }

    }



}
